<?php include '../public/header.php' ?>
<?php include '../public/header_index.php' ?>
<style>
    .minyuan_red{padding: 4px;background-color: red;border-radius: 50%;font-size: 0;margin-right: 6px;position: relative;top: -4px;}
    .minyuan_lv{padding: 4px;background-color: #19BE6B;border-radius: 50%;font-size: 0;margin-right: 6px;position: relative;top: -4px;}
    .layui-table tr td .laytp-tree-table-cell > .laytp-tree-table-cell-content{
        font-size: 13px;
    }
</style>
<body class="laytp-container">
<div id="opt_nav">
</div>

<div class="layui-card" id="search-form">
    <div class="layui-card-body">
        <form class="layui-form" id="TableSearchFormId" lay-filter="TableSearchForm" onkeydown="keyTableSearch('TableSearchForm', 'datalist')">
            <div class="layui-form-item">
                <div class="layui-row">
                    <div class="layui-col-md3">
                        <label class="layui-form-label">所属单位</label>
                        <div class="layui-input-block">
                            <div id="chanid" class="xmselect_div">
                                <div class="xmselect_title">请选择</div>
                            </div>
                        </div>
                    </div>
                    <div class="layui-col-md3">
                        <label class="layui-form-label">年份</label>
                        <div class="layui-input-block">
                            <input type="text" readonly id="year" name="year" placeholder="请选择" autocomplete="off" class="layui-input bdate_sea_y">
                        </div>
                    </div>
                    <div class="layui-col-md3">
                        <div class="layui-form-item search-div">
                            <div class="layui-form-item layui-inline">
                                <button class="laytp-btn laytp-btn-md laytp-btn-primary" id="TableSearchButton" type="button"><i class="layui-icon layui-icon-search"></i>查询</button>
                                <button class="layui-btn layui-btn-primary" onclick="listTableReset()" id="TableSearchReset" type="reset" ><i class="layui-icon layui-icon-refresh"></i>重置</button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </form>
    </div>
</div>

<div class="layui-card" id="table-card">
    <div class="layui-card-body">
        <div class="layui-row">
            <div class="layui-col-md12" id="table_list">
                <div class="layui-card-body">
                    <table id="datalist" lay-filter="datalist"></table>
                </div>
            </div>
        </div>
    </div>
</div>
<script type="text/html" id="toolbarDemo">
    <div class = "layui-btn-container">
    </div>
</script>
<script>

    var currButAuth, currButAuthArr=[], currTabData, mytable, form;
    layui.use(["laytp",'laypage','table','dropdown','form','soulTable', 'treeTable'], function () {
        var laypage = layui.laypage, table = layui.table, dropdown = layui.dropdown, form = layui.form, soulTable = layui.soulTable, treeTable=layui.treeTable;


        $('#TableSearchReset').click(function () {
            $('.xmselect_div>xm-select').find('.xm-label-block').css('display','none');
            $('.xmselect_div').append('<div class="xmselect_title">请选择</div>');
            searchTableFunc(form, table)
        });


        setSouTableExport('非主营业务收入报表', 2);
        mytable = treeTable.render({
            elem: "#datalist",id: "datalist",title: "非主营业务收入报表"
            ,url: facade.url(ask_cai_shoufei_tong),where: {}, page: false, height: 'full-140'
            ,soulSort: TabInit.soulSort,method: TabInit.method, toolbar: TabInit.toolbar, overflow: TabInit.overflow
            ,defaultToolbar: TabInit.defaultToolbar,filter: TabInit.filter
            ,request: TabInit.request,response: TabInit.response,contextmenu:get_table_contextmenu(soulTable)
            ,text: TabInit.text
            , tree: {
                iconIndex: 1        // 折叠图标显示在第几列
                , arrowType: 'arrow2'   // 自定义箭头风格
                , getIcon: function (d) {  // 自定义图标
                    // d是当前行的数据
                    if (d.children && d.children.length > 0) {  // 判断是否有子集
                        return '<i class="laytp-tree-icon laytp-tree-icon-folder"></i>';
                    } else {
                        return '<i class="laytp-tree-icon laytp-tree-icon-file"></i>';
                    }
                }
            }
            ,parseData: function (res) {



                xmselect_dan('chanid', res.data.chanid, res.data.is_chanid, function (res) {
                    setTimeout(function () {
                        searchTableFunc(form, table);
                    },100)
                })

                $("#year").val(res.data.year)
                $("#search-form").show()

                return {
                    "code": res.code,
                    "msg": res.message,
                    "count": res.data.total,
                    "data": res.data.data
                };
            }
            , cols: [[
                {type: "checkbox", fixed: 'left'}
                ,{field: 'name', title: '收入科目',width:300}
                ,{field:'year',title:'年度',align:'right'}
                ,{field:'count',title:'年度合计(元)',align:'right',templet: function(d){
                        return parseFormatNum(d.count);
                    }}
                ,{field:'mon1',title:'一月',align:'right',templet: function(d){
                        if(d.son.length > 1){
                            return parseFormatNum(d.mon1);
                        }
                        return '<span class="colorlan" onclick="account_shou_func('+d.id+','+d.chanid+',\''+d.year+'-01\')">'+parseFormatNum(d.mon1)+'</span>';
                    }}
                ,{field:'mon2',title:'二月',align:'right',event: 'account_shou2',templet: function(d){
                        if(d.son.length > 1){
                            return parseFormatNum(d.mon2);
                        }
                        return '<span class="colorlan" onclick="account_shou_func('+d.id+','+d.chanid+',\''+d.year+'-02\')">'+parseFormatNum(d.mon2)+'</span>';
                    }}
                ,{field:'mon3',title:'三月',align:'right',event: 'account_shou3',templet: function(d){
                        if(d.son.length > 1){
                            return parseFormatNum(d.mon3);
                        }
                        return '<span class="colorlan" onclick="account_shou_func('+d.id+','+d.chanid+',\''+d.year+'-03\')">'+parseFormatNum(d.mon3)+'</span>';
                    }}
                ,{field:'mon4',title:'四月',align:'right',event: 'account_shou4',templet: function(d){
                        if(d.son.length > 1){
                            return parseFormatNum(d.mon4);
                        }
                        return '<span class="colorlan" onclick="account_shou_func('+d.id+','+d.chanid+',\''+d.year+'-04\')">'+parseFormatNum(d.mon4)+'</span>';
                    }}
                ,{field:'mon5',title:'五月',align:'right',event: 'account_shou5',templet: function(d){
                        if(d.son.length > 1){
                            return parseFormatNum(d.mon5);
                        }
                        return '<span class="colorlan" onclick="account_shou_func('+d.id+','+d.chanid+',\''+d.year+'-05\')">'+parseFormatNum(d.mon5)+'</span>';
                    }}
                ,{field:'mon6',title:'六月',align:'right',event: 'account_shou6',templet: function(d){
                        if(d.son.length > 1){
                            return parseFormatNum(d.mon6);
                        }
                        return '<span class="colorlan" onclick="account_shou_func('+d.id+','+d.chanid+',\''+d.year+'-06\')">'+parseFormatNum(d.mon6)+'</span>';
                    }}
                ,{field:'mon7',title:'七月',align:'right',event: 'account_shou7',templet: function(d){
                        if(d.son.length > 1){
                            return parseFormatNum(d.mon7);
                        }
                        return '<span class="colorlan" onclick="account_shou_func('+d.id+','+d.chanid+',\''+d.year+'-07\')">'+parseFormatNum(d.mon7)+'</span>';
                    }}
                ,{field:'mon8',title:'八月',align:'right',event: 'account_shou8',templet: function(d){
                        if(d.son.length > 1){
                            return parseFormatNum(d.mon8);
                        }
                        return '<span class="colorlan" onclick="account_shou_func('+d.id+','+d.chanid+',\''+d.year+'-08\')">'+parseFormatNum(d.mon8)+'</span>';
                    }}
                ,{field:'mon9',title:'九月',align:'right',event: 'account_shou9',templet: function(d){
                        if(d.son.length > 1){
                            return parseFormatNum(d.mon9);
                        }
                        return '<span class="colorlan" onclick="account_shou_func('+d.id+','+d.chanid+',\''+d.year+'-09\')">'+parseFormatNum(d.mon9)+'</span>';
                    }}
                ,{field:'mon10',title:'十月',align:'right',event: 'account_shou10',templet: function(d){
                        if(d.son.length > 1){
                            return parseFormatNum(d.mon10);
                        }
                        return '<span class="colorlan" onclick="account_shou_func('+d.id+','+d.chanid+',\''+d.year+'-10\')">'+parseFormatNum(d.mon10)+'</span>';
                    }}
                ,{field:'mon11',title:'十一月',align:'right',event: 'account_shou11',templet: function(d){
                        if(d.son.length > 1){
                            return parseFormatNum(d.mon11);
                        }
                        return '<span class="colorlan" onclick="account_shou_func('+d.id+','+d.chanid+',\''+d.year+'-11\')">'+parseFormatNum(d.mon11)+'</span>';
                    }}
                ,{field:'mon12',title:'十二月',align:'right',event: 'account_shou12',templet: function(d){
                        if(d.son.length > 1){
                            return parseFormatNum(d.mon12);
                        }
                        return '<span class="colorlan" onclick="account_shou_func('+d.id+','+d.chanid+',\''+d.year+'-12\')">'+parseFormatNum(d.mon12)+'</span>';
                    }}
            ]]
            , done: function (res) {
                mytable.expandAll();
                mytable.expandAll();
                mytable.expandAll();
                mytable.expandAll();
                mytable.expandAll();
                mytable.expandAll();
                mytable.expandAll();
                mytable.expandAll();
                mytable.expandAll();
                mytable.expandAll();
                mytable.expandAll();
                mytable.expandAll();
                mytable.expandAll();
                mytable.expandAll();
                mytable.expandAll();
                mytable.expandAll();
                mytable.expandAll();
            }
        });

        listTableSearch(form, table);
    });


    function account_shou_func(budid, chanid, yearmonth) {
        var typestr = '2,8,9,11,14';
        openPage('../account_shou/tong.php?budid='+budid+'&chanid='+chanid+'&month='+encodeURI(yearmonth)+'&typestr='+typestr, '80%', '80%');
    }



    function searchTableFunc(form, table) {
        var data = form.val('TableSearchForm');
        mytable.reload('datalist', {
            where: data
        });
    }


</script>
</body>
</html>
